#include <iostream>
#include <stack>
#include <string>
using namespace std;
int evaluatePostfix(const string &expression) {
    stack<int> stack;
    for (char ch : expression) {
        if (ch >= '0' && ch <= '9') {
            stack.push(ch - '0');
        } else if (ch == ' ') {
            continue;
        } else {
            int operand2 = stack.top(); stack.pop();
            int operand1 = stack.top(); stack.pop();

            switch (ch) {
                case '+': stack.push(operand1 + operand2); break;
                case '-': stack.push(operand1 - operand2); break;
                case '*': stack.push(operand1 * operand2); break;
                case '/': stack.push(operand1 / operand2); break;
                default: 
                    cerr << "Invalid operator: " << ch << endl;
                    return -1;
            }
        }
    }
    return stack.top();
}

int main() {
    string expression;
    cout << "Enter a postfix expression (e.g., 53+82-*): ";
    getline(cin, expression); 
    int result = evaluatePostfix(expression);
    if (result != -1) {
        cout << "The result of the expression is: " << result << endl;
    }
    return 0;
}
